package model;

import java.awt.Desktop;
import java.io.File;
import java.util.ArrayList;

public class Movie {

    /**.
     * movie title
     */
    private String title;
    /**.
     * year
     */
    private int year;
    /**.
     * search
     */
    private String search;
    /**.
     * plot
     */
	private String plot;
	/**.
	 * path
	 */
	private String path;
	/**.
	 * poster
	 */
	private String poster;
	/**.
	 * release
	 */
	private ReleaseDate release;
	/**.
	 * rating
	 */
	private Rating rating;
	/**.
	 * runtime
	 */
	private String runtime;
	/**.
	 * genres
	 */
	private ArrayList<String> genres;
	/**.
	 * actors
	 */
	private ArrayList<String> actors;
	/**.
	 * directors
	 */
	private ArrayList<String> directors;
	/**.
	 * writers
	 */
	private ArrayList<String> writers;
	/**.
	 * classified
	 */
	private String classified;
	/**.
	 * website
	 */
	private String website;
	/**.
	 * production
	 */
	private String production;
	/**.
	 * box Office
	 */
	private String boxOffice;
	/**.
	 * completed
	 */
	private boolean completed;

	/**.
	 * Default Constructor
	 */
	public Movie() {
		genres = new ArrayList<String>();
		actors = new ArrayList<String>();
		directors = new ArrayList<String>();
		writers = new ArrayList<String>();
	}

	/**.
	 * Second constructor
	 * @param path
	 * @param search
	 */
	public Movie(final String path, String search){
		this.path = path;
		this.search = search;
		release = new ReleaseDate();
		rating = new Rating();
		genres = new ArrayList<String>();
		actors = new ArrayList<String>();
		directors = new ArrayList<String>();
		writers = new ArrayList<String>();
		completed = false;
	}

	/**.
	 * Play the movie with the default video player of the system
	 */
	public final void play(){
		Desktop desktop = Desktop.getDesktop();
		if (desktop.isSupported(Desktop.Action.OPEN)) {
		     try{  
		          desktop.open(new File(this.path));
		     } catch (Exception e) {
		          e.printStackTrace();
		     }
		}
	}

	/**.
	 * Get all the genres in a single string
	 * @return the genre
	 */
	public final String genres(){
		String str = null;
		str = genres.get(0);
		for (int i = 1; i < genres.size(); i++) {
			str += ", " + genres.get(i);
		}
		return str;
	}

	/**.
	 * Get all the actors in a single string
	 * @return actors
	 */
	public final String actors() {
		String str = null;
		str = actors.get(0);
		for (int i = 1; i < actors.size(); i++) {
			str += ", " + actors.get(i);
		}
		return str;
	}

	/**.
	 * Get all the directors in a single string
	 * @return directors
	 */
	public final String directors() {
		String str = null;
		str = directors.get(0);
		for (int i = 1; i < directors.size(); i++) {
			str += ", " + directors.get(i);
		}
		return str;
	}

	/**.
	 * Get all the writers in a single string
	 * @return writers
	 */
	public final String writers() {
		String str = null;
		str = writers.get(0);
		for (int i = 1; i < writers.size(); i++) {
			str += ", " + writers.get(i);
		}
		return str;
	}

	/**.
	 * return title
	 * @return title
	 */
	public final String getTitle() {
		return title;
	}

	/**.
	 * set title
	 * @param title
	 */
	public final void setTitle(String title) {
		this.title = title;
	}

	public String getSearch() {
		return search;
	}

	public void setSearch(String search) {
		this.search = search;
	}

	public String getPlot() {
		return plot;
	}

	public void setPlot(String synopsis) {
		this.plot = synopsis;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public String getPoster() {
		return poster;
	}

	public void setPoster(String imagePath) {
		this.poster = imagePath;
	}

	public ReleaseDate getRelease() {
		return release;
	}
	
	public void setRelease(ReleaseDate release){
		this.release=release;
	}
	
	public void setRating(Rating rating){
		this.rating=rating;
	}

	public Rating getRating() {
		return rating;
	}

	public String getRuntime() {
		return runtime;
	}

	public void setRuntime(String runtime) {
		this.runtime = runtime;
	}

	public ArrayList<String> getActors() {
		return actors;
	}

	public void addActors(String actor) {
		this.actors.add(actor);
	}

	public ArrayList<String> getGenre() {
		return genres;
	}

	public void addGenre(String genre) {
		this.genres.add(genre);
	}

	public ArrayList<String> getDirector() {
		return directors;
	}

	public void addDirector(String director) {
		this.directors.add(director);
	}

	public ArrayList<String> getWriter() {
		return writers;
	}

	public void addWriter(String writer) {
		this.writers.add(writer);
	}

	public String getClassification() {
		return classified;
	}

	public void setClassification(String classified) {
		this.classified = classified;
	}

	public String getWebsite() {
		return website;
	}

	public void setWebsite(String website) {
		this.website = website;
	}

	public String getProduction() {
		return production;
	}

	public void setProduction(String production) {
		this.production = production;
	}

	public String getBoxOffice() {
		return boxOffice;
	}

	public void setBoxOffice(String boxOffice) {
		this.boxOffice = boxOffice;
	}

	public boolean isCompleted() {
		return completed;
	}

	public void setCompleted(boolean completed) {
		this.completed = completed;
	}

	public int getYear() {
		return year;
	}

	public void setYear(int year) {
		this.year = year;
	}
	
}
